import Redis from 'ioredis';
import 'dotenv/config';

const redis = new Redis({
    host: process.env.REDIS_HOST,
    port: Number(process.env.REDIS_PORT) || 6379,
    password: process.env.REDIS_PASSWORD || undefined,
    db: Number(process.env.REDIS_DB) || 0,
});

redis.on('error', (err) => console.error('[Redis] error:', err));
redis.on('connect', () => console.log('[Redis] connected'));

export default redis;